﻿using System;
using System.Windows;
using System.Windows.Controls;
using QDP.Platform.Services;
using System.Windows.Media;

namespace Apps.Common
{
    public class MessageTip : UserControl, IMessageService
    {
        public MessageBoxResult Show(MessageContract Message)
        {
            if (Message == null)
                return MessageBoxResult.Cancel;

            if (Messaged != null)
            {
                Messaged(this, new MessageEventArgs() { Message = Message });
            }
            if (Message.Button == MessageBoxButton.OK)
            {
                var dialog = new ChildWindow()
                {
                    Content = Message.Message,
                    Title = Message.Title,
                    MinHeight = 250,
                    MinWidth = 400,
                    OverlayOpacity = 0,
                    OverlayBrush = new SolidColorBrush(Colors.Transparent)

                };
                dialog.Show();
                return MessageBoxResult.OK;
            }
            else
            {
                return MessageBox.Show(Message.Message, Message.Title, Message.Button);
            }
        }
        public event EventHandler<MessageEventArgs> Messaged;
        public MessageBoxResult Show(string Content)
        {
            return Show(new MessageContract()
            {
                Title = "系统提示",
                Message = Content,
                Button = MessageBoxButton.OK
            });
        }
    }
}
